<!doctype html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Binicare</title>
	<script src="/h5_vote/js/jquery-1.11.0.min.js"></script>
	<link rel="stylesheet" href="/h5_vote/css/style.css">
</head>
<body>

<div class="logo">
	<img src="/h5_vote/img/logo.png">
</div>

<div class="votenotice">Which color you prefer for this waterflosser？</div>

<div class="votelist" id="votelist">

</div>

<div class="votebsub">
	<button class="votebtn" onclick="up_votes()">submit</button>
</div>

<style>
	.card_act a{
		display: inline-block;
		*display: inline;
		*zoom: 1;
		width: 4rem;
		height: 1.5rem;
		text-align: center;
		line-height: 1.4rem;
		border-radius: 0.2rem;
	}
	.card_act a.card_act_edit{
		color: #f00;
		border: 1px solid #f00;
	}
	.card_act a.card_act_stop{
		color: #fff;
		border: 1px solid #f00;
		background: #f00;
	}
	.overlay_container {
		position: fixed;
		z-index: 100003;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,.15);
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-orient: vertical;
		-webkit-flex-flow: column;
		-webkit-flex-direction: column;
		-ms-flex-direction: column;
		flex-direction: column;
		-webkit-transition-property: opacity;
		-webkit-transition-duration: 100ms;
		-webkit-backface-visibility: hidden
	}

	.overlay_container:after,.overlay_container:before {
		content: '';
		display: block;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		-ms-flex: 1;
		flex: 1
	}

	.overlay_container.unmasked {
		background: transparent;
		pointer-events: none
	}

	.overlay_container.beforeFadeIn {
		opacity: 0
	}

	.overlay_container.afterFadeOut {
		opacity: 0
	}

	.overlay_content_container {
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-orient: horizon;
		-webkit-flex-flow: row;
		-webkit-flex-direction: row;
		-ms-flex-direction: row;
		flex-direction: row
	}

	.overlay_content_container:after,.overlay_content_container:before {
		content: '';
		display: block;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		-ms-flex: 1;
		flex: 1
	}

	.overlay_content {
		-webkit-transition-property: -webkit-transform;
		-webkit-transition-duration: 150ms;
		-webkit-transform-origin: 50% 50%;
		pointer-events: auto
	}

	.toast {
		width: 210px;
		padding: 16px;
		font-size: 16px;
		line-height: 20px;
		background-color: rgba(0,0,0,.9);
		border-radius: 8px;
		color: #fff;
		text-align: center;
		z-index: 100000;
	}


	.cover{
		display: none;
		position: fixed;
		width: 100%;
		height: 100%;
		z-index: 999;
	}
	.cover_bg{
		position: absolute;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,0.6);
		z-index: 1;
	}
	.cover_con{
		background: #fff;
		padding: 1rem;
		margin: 1rem;
		position: relative;
		z-index: 2;
		top: 50%;
		left: 0;
		transform: translateY(-50%);
	}
	.cover_close{
		position: absolute;
		right: 0.25rem;
		top: 0.25rem;
		border: 0.1rem solid #666;
		color: #666;
		font-weight: bold;
		width: 1.7rem;
		height: 1.7rem;
		line-height: 1.5rem;
		text-align: center;
		border-radius: 0.85rem;
	}
	.cover_title{
		padding-right: 2rem;
	}
	.cover_img{
		padding: 0.25rem;
		text-align: center;
	}
	.cover_img img{
		width: 6rem;
		height: 6rem;
	}
	.cover_title2{
		font-size: 0.7rem;
	}
	.cover_text{
		font-size: 0.7rem;
	}
	.cover_btn{
		text-align: center;
		color: #fff;
		background: #333;
		margin-top: 0.5rem;
		height: 2rem;
		line-height: 2rem;
	}
</style>
<div class="loading" style="display: none;"></div>
<div class="overlay_container j_overlay_container unmasked beforeFadeIn" style="display: none;"><div class="overlay_content_container j_overlay_content_container"><div class="overlay_content"><div id="toast" class="toast"></div></div></div></div>
<div id="bodyhidden" style="display: none;"></div>


<script type="text/javascript">
	function fmloaddingend(id) {
		$(id).hide();
	}

	function fmloadding(id, text) {
		$(id).show();
		$(id).removeClass("beforeFadeIn");

		setTimeout(function () {
			$(id).hide();
			$(id).addClass("beforeFadeIn");
		},3000)
		$('#toast').html(text);
	}
</script>

</body>
<script>
	var voteclick = function () {
		var uploadSelectList = document.querySelectorAll(".voteinner");
		if (uploadSelectList.length > 0) {
			$.each(uploadSelectList, function (i, v) {
				$(this).click(function(){
					var votenum = $(".voteCheck").length;
					var votemax = {:sysconfig('votes','votes_selectnum')};
					if(votemax == 0){
						votemax = 9999;
					}
					if($(this).hasClass("voteCheck")){
						$(this).removeClass("voteCheck")
					}
					else{
						if(votenum>=votemax){
							return
						}
						else{
							$(this).addClass("voteCheck")
						}
					}
				});
			});
		}
	}

	get_votes_list()
	function get_votes_list(){
		var dataform = {
			'status': 1,
		};
		$.ajax({
			url: "admin/Ajax/votes_list",
			data: dataform,
			type: "Post",
			async: false,
			cache: false,
			dataType: "json",
			success: function (res) {
				if (res.code == 1) {
					set_data(res.data);
					voteclick();
					return
				} else {
					return set_data('');
				}
			},
			error:function (result) {
				console.log(result)
			}
		})
	}

	function set_data(data) {
		var str = '';
		$.each(data, function (i, val) {
			str = str + '<div class="voteinner" data-code="'+val.code+'" data-id="'+val.id+'"><img src="'+val.logo+'"></div>';

		});
		str = str ? str : '';
		$("#votelist").html(str);
	}


	function up_votes(){
		var uploadSelectList = document.querySelectorAll(".voteinner");
		if (uploadSelectList.length > 0) {
			var id = new Array();
			$.each(uploadSelectList, function (i, v) {
					if($(this).hasClass("voteCheck")){
						id.push({id:$(this).data('id'),code:$(this).data('code')});
					}
			});
		}
		var dataform = {
			'id': id,
		};
		$.ajax({
			url: "admin/Ajax/up_votes",
			data: dataform,
			type: "Post",
			async: false,
			cache: false,
			dataType: "json",
			success: function (res) {
				if (res.code == 1) {
					fmloadding('.overlay_container', res.msg);
					setTimeout(function () {
						top.window.location = "h5_vote/result.html";
					},2000)

					return
				};
				if (res.code == 2) {
					fmloadding('.overlay_container', res.msg);
					setTimeout(function () {
						top.window.location = "h5_vote/result.html";
					},2000)
					return ;
				};
				if (res.code == -1) {
					fmloadding('.overlay_container', res.msg);
					return ;
				};

			},
			error:function (result) {
				fmloadding('.overlay_container', res.msg);
			}
		})
	}




</script>
</html>